<template>
	<view class="ta-container">
		<view class="ta-top-view">
			<view class="ta-title">TA们都在参与匹配哦～</view>
			<view class="ta-right-c">
				<view class="ta-right" @click="clickToMatchList">查看全部会员</view>
				<image src="/static/images/home2/home_ta_arrow.png"></image>
			</view>
			
		</view>
		<scroll-view class="scroll-view_H" scroll-x="true" show-scrollbar="false" >
			<view class="space-ver"></view>
			<view class="scroll-view-item_H" v-for="(item,index) in dataList" :key="index">
					<view class="card-container" @click="toUserDetail(item.userinfo)">
						<view class="avatar-img-c">
							<image class="auth-icon" v-if="showAuth(item.userinfo)" :src="home_auth_icon"></image>
							<image class="avatar-img" :src="getAvatar(item.userinfo)" mode="aspectFill"></image>
						</view>
						
						<view class="zhiye-title">{{getZhiye(item.userinfo)}}</view>
						<view class="age-sex-c" :class="{'age-woman-sex':item.userinfo.sex == 'F'}">
							<image  class="sex-img" :src="getSexImg(item.userinfo)"></image>
							<view class="sex-title" :class="{'sex-woman-title':item.userinfo.sex == 'F'}">{{getTaAges(item.userinfo.birthday)}}</view>
						</view>
						<view class="zhuanfa-btn">
							{{"转发"+(item.share_count || 0)}}
						</view>
					</view>
			</view>
			<view class="space-ver"></view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		ta_sex_man,
		ta_sex_woman,
		home_auth_icon
	} from '../home_image_tool.js'
	import { getAges } from "@/util/tool.js";
	export default {

		props: {
			dataList:Array
		},
		data() {
			return {
				ta_sex_man,
				ta_sex_woman,
				home_auth_icon
			}
		},
		methods: {
			getAvatar(userInfo){
				if (userInfo === undefined) {
					return '';
				}
				return userInfo.avatar || "";
			},
			getZhiye(userInfo){
				if (userInfo === undefined) {
					return '';
				}
				return userInfo.job || "";
			},
			getSexImg(userInfo){
				return userInfo.sex == "F" ? ta_sex_woman : ta_sex_man;
			},
			showAuth(userinfo){
				return  userinfo.certificated;
			},
			toUserDetail(userinfo){
				let url = "/pages/home2/detail2/detail2?user_id=" + userinfo.user_id;
				   uni.navigateTo({
				     url: url,
				   });
			},
			getTaAges(birthday) {
			  let birthdayStr = birthday || "";
			  if (birthdayStr == "") {
			    return "";
			  } else {
			    return getAges(birthdayStr);
			  }
			},
			clickToMatchList(){
				console.log("clickToMatchList");
				let userInfo = getApp().globalData.userInfo || {};
				let activity = userInfo.activity || false;
				if(activity){
					uni.navigateTo({
					  url: "/pages/match-list/match-list",
					});
				}else{
					uni.showToast({
						icon:"none",
						title:"报名后即可查看，赶紧去报名吧~"
					})
				}
			}
		},
		mounted() {
			
		}
	}
</script>

<style scoped lang="scss">
	* {
		box-sizing: border-box;
	}
	.ta-container {
		flex-direction: column;
		
		.ta-top-view{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 30rpx;
			.ta-title {
				margin-left: 16px;
				font-weight: 500;
				font-size: 25rpx;
				line-height: 36rpx;
				color: #333333;
			}
			.ta-right-c{
				display: flex;
				align-items: center;
				margin-right: 10px;
				border-style: solid;
				border-width: 1rpx;
				border-color: #FF5E6A;
				border-radius: 6rpx;
				padding: 6rpx 12rpx;
				.ta-right{
					color: #FF5E6A;
					font-size: 22rpx;
					margin-right: 2px;
				}
				image{
					width: 20rpx;
					height: 16rpx;
				}
			}
			
		}

		

		.scroll-view_H {
			white-space: nowrap;
			width: 100%;
			padding-top: 32rpx;
			padding-bottom: 52rpx;
		}
		.scroll-view-item_H {
			display: inline-block;
			line-height: 300rpx;
			text-align: center;
			font-size: 36rpx;
			width: 200rpx;
			margin-right: 12rpx;
			
			.card-container{
				width: 100%;
				height: 100%;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				.avatar-img-c{
					display: flex;
					position: relative;
					width: 200rpx;
					height: 200rpx;
					.avatar-img{
						width: 200rpx;
						height: 200rpx;
						border-radius: 8rpx;
						position: relative;
					}
					.auth-icon{
						bottom: -2rpx;
						left: -2px;
						position: absolute;
						width: 46px;
						height: 14px;
						z-index: 100;
					}
				}
				
				.zhiye-title{
					margin-top: 20rpx;
					font-weight: 400;
					font-size: 22rpx;
					line-height: 30rpx;
					letter-spacing: -0.3px;
					color: #7E7D7D;
					// 展示一行超过省略
					display: inline-block;
					white-space: nowrap; 
					width: 100%; 
					overflow: hidden;
					text-overflow:ellipsis;
				}
				.age-sex-c{
					margin-top: 14rpx;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: center;
					padding: 0 6rpx;
					background: rgba(74, 158, 255, 0.1);
					border-radius: 11rpx;
					height: 22rpx;
					.sex-img{
						width: 14rpx;
						height: 14rpx;
						margin-right: 4rpx;
					}
					.sex-title{
						font-weight: 400;
						font-size: 18rpx;
						line-height: 22rpx;
						letter-spacing: -0.3px;
						color: #4A9EFF;
					}
					.sex-woman-title{
						color: #FF5E98;
					}
				}
				.age-woman-sex{
					background: rgba(255, 94, 152, 0.1);
				}
				
				.zhuanfa-btn{
					margin-top: 20rpx;
					height: 40rpx;
					background: #FFFFFF;
					border-radius: 20rpx;
					border:1px solid #FF5E98;
					padding: 0 26rpx;
					text-align: center;
					
					font-weight: 500;
					font-size: 22rpx;
					line-height: 40rpx;
					letter-spacing: -0.3px;
					color: #FF5E98;
				}
			}
			
		}
		.space-ver {
			display: inline-block;
			width: 32rpx;
		}
	}
</style>
